//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

package org.ryzom.nel.misc;

public class CEventServer {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CEventServer(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CEventServer obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CEventServer(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CEventServer() {
    this(nelmiscJNI.new_CEventServer(), true);
  }

  public void postEvent(SWIGTYPE_p_NLMISC__CEvent event) {
    nelmiscJNI.CEventServer_postEvent(swigCPtr, this, SWIGTYPE_p_NLMISC__CEvent.getCPtr(event));
  }

  public void pump(boolean allWindows) {
    nelmiscJNI.CEventServer_pump__SWIG_0(swigCPtr, this, allWindows);
  }

  public void pump() {
    nelmiscJNI.CEventServer_pump__SWIG_1(swigCPtr, this);
  }

  public void addListener(CClassId id, IEventListener listener) {
    nelmiscJNI.CEventServer_addListener(swigCPtr, this, CClassId.getCPtr(id), id, IEventListener.getCPtr(listener), listener);
  }

  public void removeListener(CClassId id, IEventListener listener) {
    nelmiscJNI.CEventServer_removeListener(swigCPtr, this, CClassId.getCPtr(id), id, IEventListener.getCPtr(listener), listener);
  }

  public void addEmitter(IEventEmitter emitter) {
    nelmiscJNI.CEventServer_addEmitter(swigCPtr, this, IEventEmitter.getCPtr(emitter), emitter);
  }

  public void removeEmitter(IEventEmitter emitter) {
    nelmiscJNI.CEventServer_removeEmitter(swigCPtr, this, IEventEmitter.getCPtr(emitter), emitter);
  }

}
